﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace paipai
{
    public partial class Regist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Bll.CUserBasic cUser = Bll.CUserBasicManage.CreateBasicUser();
            cUser.ID = System.Guid.NewGuid().ToString();
            cUser.firstName = FirstName.Text.Trim();
            cUser.lastName = LastName.Text.Trim();
            cUser.email = EmailAddr.Text.Trim();
            cUser.country = DropDownList_Country.SelectedValue;
            cUser.name = UserName.Text.Trim() ;
            cUser.password = Bll.CInCode.MyMD5(Password.Text.Trim());

            cUser.rankID = 0;
            //页面上的需求缺失
            cUser.phone = "111111";
            cUser.address = "aaaaa";
            cUser.postcode = "aaaaa";

            //
            var cUserExtend = Bll.CUserExtendManage.CreateExtendUser();
            cUserExtend.ID = cUser.ID;
            cUserExtend.safePassword = cUser.password;
            cUserExtend.bid = 0;
            cUserExtend.count = Bll.CCommonFunc.GetRandomDigitalNum();
            cUserExtend.eCash = 0;
            cUserExtend.freeBid = 0;
            cUserExtend.availableTime = DateTime.Now;
            //

            if(Bll.CUserBasicManage.Save(cUser)== null)
            {
                // insert error
            }
            else if (Bll.CUserExtendManage.Save(cUserExtend) == null)
            {
                // insert error
            }  
            else
            {
                Session.Add("UserID", cUser.ID);
                Response.Redirect("HomePage.aspx");
            }

        }
    }
}